import java.util.Scanner;

public class demo07 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        int k=sc.nextInt();
        for (int i = 0; i < n; i++) {
            int j=i-k;
            if(j<0){
                j=0;
            }
            int len=2*k+1+j;
            if(len>n){
                len=n;
            }
            int min=arr[j];
            for (int l = j; l < len; l++) {
                if(arr[l]<min){
                    min=arr[l];
                }
            }
            System.out.print(min+" ");
        }
    }
}
